package com.kcwl.carrier.infrastructure.helper;

import com.kcwl.carrier.infrastructure.config.SecurityConfig;
import com.kcwl.ddd.application.constants.ProductEnum;
import com.kcwl.ddd.infrastructure.session.SessionContext;
import com.kcwl.framework.cache.ICacheService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 刘旭超
 * @date 2022年06月16日 16:35
 * @Description
 */
@Service
public class SessionDataHelper {

    @Autowired
    protected ICacheService stringCache;

    @Autowired
    private SecurityConfig securityConfig;

    public Integer getSessionTimeout() {
        Integer sessionTimeout;
        // web端过期时间
        Integer product = SessionContext.getSessionData().getProduct();
        if (ProductEnum.CARRIER_APP.getId().equals(product) || ProductEnum.SHIPPER_APP.getId().equals(product)) {
            sessionTimeout = securityConfig.getAppSessionTimeout();
        } else {
            sessionTimeout = securityConfig.getWebSessionTimeout();
        }
        return sessionTimeout;
    }

}
